package com.liuyk.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.liuyk.entity.Channel;
import com.liuyk.main.activity.R;

/**
 * 拖拽GridView适配器
 *
 * Created by Administrator on 2015/9/11.
 */
public class DragAdapter extends MyBaseAdapter<Channel> {

    public DragAdapter(Context context) {
        super(context);
    }

    @Override
    public int getResource() {
        return R.layout.channel_grid_view;
    }

    @Override
    public View refactorSetView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = (ViewHolder) convertView.getTag();
        if(viewHolder == null){
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }
        final Channel channel = getData(position);
        viewHolder.channelName.setText(channel.getChannelName());
        return convertView;
    }

    private final class ViewHolder{
        private final TextView channelName;
        public ViewHolder(View convertView){
            channelName = convertView.findViewById(R.id.channel_name);
        }
    }

}
